package com.example.fan.airline_reservation;

import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.os.Handler;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Toast;

import com.example.fan.airline_reservation.Adapter.GuidePagerAdapter;

public class MainActivity extends AppCompatActivity {


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
      //  setContentView(R.layout.activity_main);
       // initView();
        boolean ifFirst=isUseFirst();
        if (ifFirst) {
            setContentView(R.layout.activity_main);
            initView();
        }
        else {
            Intent intent=new Intent(this,WelcomeActivity.class);//换成要跳转的activity
            startActivity(intent);
            finish();
        }

    }

    public boolean isUseFirst() {
        SharedPreferences setting = this.getSharedPreferences("printer",MODE_PRIVATE);
        boolean first = setting.getBoolean("first",true);
        return first;
    }


    private void initView() {
        ViewPager MainViewPger=findViewById(R.id.main_vp_pager);
        int[] myImage={R.mipmap.sliding1,R.mipmap.sliding2,R.mipmap.sliding3,R.mipmap.sliding4};
        GuidePagerAdapter adapter=new GuidePagerAdapter(this,myImage);
        MainViewPger.setAdapter(adapter);

    }

    public void jumpToNext(View view) {
        //Toast.makeText(MainActivity.this,"tiaoguo",Toast.LENGTH_SHORT).show();
        SharedPreferences usesetting=this.getSharedPreferences("printer",MODE_PRIVATE);
        SharedPreferences.Editor edit = usesetting.edit();
        edit.putBoolean("first",false);
        edit.commit();
        Intent intent=new Intent(this,Sign_in.class);//换成要跳转的activity
        startActivity(intent);
        finish();
    }


}
